/*
#####################################################################
####################	   T R I B U I T 		#####################
#####################################################################

Copyright (C) 2010  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.


########################################################################
*/
package SystemTray;

import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.Timer;
import Storage.Word;

/**
 * @author Christoph Schnack
 *
 */
class PopUpWords implements ActionListener{
	Word[] words;
	Random rnd = new Random();
	Timer timer;
	SystemTray tray;
	boolean inverse;
	public PopUpWords(boolean inv,Word[] wrds,int delay, SystemTray tr){
		words=wrds;
		timer = new Timer(delay,this);
		tray=tr;
		inverse=inv;
	}
	public void start(){timer.start();}
	public void stop(){timer.stop();}
	
	public void actionPerformed(ActionEvent e){
		Word word = words[rnd.nextInt(words.length-1)];
		if(!inverse)tray.getTrayIcons()[0].displayMessage(word.getFullTermA() + "  -  " + word.getFullTermB(), null, TrayIcon.MessageType.NONE);
		else tray.getTrayIcons()[0].displayMessage(word.getFullTermB() + "  -  " + word.getFullTermA(), null, TrayIcon.MessageType.NONE);
	}
}
